﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RayDen.RayEngine.Core.Interface;
using RayDen.RayEngine.Core.Types;

namespace RayDen.RayEngine.Engines.Complex
{
    public class ComplexPathSampler : PathSamplerBase
    {

        protected List<PathSamplerBase> samplers;
        protected int currentSampler;


        public ComplexPathSampler(PathSamplerBase[] samplers)
        {
            this.samplers = new List<PathSamplerBase>(samplers);
        }

        public void SwitchSampler()
        {
            if (currentSampler == samplers.Count - 1)
            {
                currentSampler = 0;
            }
            else
            {
                currentSampler++;
            }
        }

        public virtual void EvalState()
        {
            
        }


        public override void Advance(RayBuffer rayBuffer, SampleBuffer consumer)
        {
            this.samplers[currentSampler].Advance(rayBuffer, consumer);
        }

        public override bool FillRayBuffer(RayBuffer rayBuffer)
        {
            return this.samplers[currentSampler].FillRayBuffer(rayBuffer);
        }

        public override void InitPath(IPathProcessor buffer)
        {
            this.samplers[currentSampler].InitPath(buffer);
        }

        public override void Splat(SampleBuffer sampleBuffer)
        {
            this.samplers[currentSampler].Splat(sampleBuffer);
            EvalState();
        }
    }
}
